<?php

namespace App\V3\V3_2\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class MaterielContentsModel extends Model
{
    use HasFactory;

    protected $table = 'materiel_content';

    protected $dateFormat = 'U';//这个时间字段被为被格式化为UNIX 时间戳的形式存储

    protected $dates = [
        'purchase_time'
    ];

    static public function getMaterielId($condition, $userId)
    {
        return self::select('materiel_id')->from('materiel_content as a')
            ->leftJoin('materiel_type as b', 'b.id', '=', 'a.type_id')
            ->where($condition)->where('a.main_id', $userId)->get()->toArray();
    }
}
